home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v7n17.arc / MESSAGE.BAS < prev    next >
BASIC Source File  |  1988-09-13  |  2KB  |  67 lines

  1. DEFINT A-Z
  2. SCREEN 2
  3.  
  4. 'set up message and window location
  5.  
  6. MESSAGE$ = ".........The quick brown fox jumped over the lazy dog"
  7. LEFT = 220
  8. RIGHT = 420
  9. TOP = 8
  10. LETNUM = 0
  11. COLUMN = 8
  12.  
  13. LINE (LEFT - 2, TOP - 2)-(RIGHT + 2, TOP + 9), 1, B 'draw box around window
  14. DIM BUFF(2 + INT((RIGHT - LEFT + 7) / 8) * 4)       'space for buffer
  15. DEF SEG = &HF000                                    'segment of ROM characters
  16.  
  17. '  To get a smooth crawl, we must use timed interrupts.  However,
  18. '  ON TIMER has a minimum interval of 1 second, which is not fast enough. 
  19. '  We are forced to use ON PLAY with a song consisting of a single rest. 
  20.  
  21. PLAY "MB T130 L32 N0"                     'set up "song"
  22. ON PLAY(1) GOSUB MOVEIT                   'set up timed interrupt
  23. PLAY ON                                   'enable timed interrupt
  24.  
  25. '  A foreground task can be executing here.  In this case, the time
  26. '  of day is printed on the screen. 
  27.  
  28. WHILE INKEY$ = ""
  29.     LOCATE 5, 37
  30.     PRINT TIME$
  31. WEND
  32. END
  33.  
  34. '  Interrupt handler for ON PLAY
  35. '
  36. '  MOVEIT receives control at regular intervals through the ON PLAY
  37. '  statement.  It takes the current image in the window and shifts it
  38. '  right one column.  It then adds a new column at the left hand edge. 
  39. '  This creates a message that "crawls" from left to right. 
  40.  
  41. MOVEIT:
  42.     GET (LEFT, TOP)-(RIGHT - 1, TOP + 7), BUFF    'get current image
  43.     PUT (LEFT + 1, TOP), BUFF, PSET               'shift image to right
  44.  
  45.     '  A new column is added at the left.  This is constructed using the
  46.     '  character pattern table located in ROM at F000:FA6E
  47.  
  48.     COLUMN = COLUMN + 1
  49.     IF COLUMN = 9 THEN
  50.        COLUMN = 1
  51.        LETNUM = LETNUM + 1                        'start a new letter
  52.        IF LETNUM > LEN(MESSAGE$) THEN LETNUM = 1  'wrap around if necessary
  53.  
  54.        'compute offset into pattern table for the new letter
  55.        OFFSET = &HFA6E + ASC(MID$(MESSAGE$, LEN(MESSAGE$) - LETNUM + 1, 1)) * 8
  56.     END IF
  57.  
  58.     'copy one column of the pattern into the left edge of the window
  59.     FOR ROW = 0 TO 7
  60.         BYTE = OFFSET + ROW
  61.         BIT = (PEEK(BYTE) AND 2 ^ (COLUMN - 1))
  62.         IF BIT = 0 THEN PRESET (LEFT, TOP + ROW) ELSE PSET (LEFT, TOP + ROW)
  63.     NEXT
  64.  
  65.     PLAY "MB N0"                                  'create a new "song"
  66. RETURN
  67.